public class Solution423 {
    public String originalDigits(String s) {
        int[] hash=new int[26];
        int[] count=new int[10];
        for (char i:s.toCharArray()){
            hash[i-'a']++;
        }
        count[0]=hash['z'-'a'];
        hash['r'-'a']-=count[0];
        hash['o'-'a']-=count[0];
        count[2]=hash['w'-'a'];
        hash['o'-'a']-=count[2];
        count[6]=hash['x'-'a'];
        hash['i'-'a']-=count[6];
        count[4]=hash['u'-'a'];
        hash['f'-'a']-=count[4];
        hash['o'-'a']-=count[4];
        hash['r'-'a']-=count[4];
        count[5]=hash['f'-'a'];
        hash['i'-'a']-=count[5];
        hash['v'-'a']-=count[5];
        count[7]=hash['v'-'a'];
        hash['n'-'a']-=count[7];
        count[1]=hash['o'-'a'];
        hash['n'-'a']-=count[1];
        count[9]=hash['n'-'a']/2;
        hash['i'-'a']-=count[9];
        count[8]=hash['i'-'a'];
        count[3]=hash['r'-'a'];
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=0;i<10;i++){
            for (int j=0;j<count[i];j++){
                stringBuilder.append(i);
            }
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution423().originalDigits("owoztneoer"));
    }
}
